/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */
var checkSymmetricTree = function(root) {
    if(root == null) return true
    const isSymmetric = function(left, right) {
        if(left == null && right == null) return true
        if(left == null && right !== null) return false
        if(left !== null && right == null) return false
        if(left.val === right.val) {
            return isSymmetric(left.left, right.right) && isSymmetric(left.right, right.left)
        } else {
            return false
        }
    }
    isSymmetric(root.left, root.right)
};